package homework.day07; 
 /*
 @Time: 2022/7/19 19:28
 @Author:GShuai
 @File:Test05.class
 @Software:IntelliJ IDEA
*/

/**
 * 修改下面代码的编译
 *
 */
public class Test05 {
    public static void main(String[] args) {
        //错误是没有重写run方法来定义线程任务,线程不能用Lambda所以只能重写run方法
//		Thread t1 = new Thread() {
//			Foo.dosome();
//		};

        Thread t1 = new Thread() {
             public void run() {
                 Foo.dosome();
             }
        };

//		Thread t2 = new Thread() {
//			Foo.dosome();
//		};
		Thread t2 = new Thread() {
		    public void run() {
                Foo.dosome();
            }
		};
        t1.start();
        t2.start();
    }
}
class Foo{
    public static void dosome() {
        //静态方法中看不到this
//        synchronized (this) {
        synchronized (Foo.class) {
            System.out.println("hello!");
        }
    }
}